package com.example.synthesize.Set和Map;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

/**
 * Created by IntelliJ IDEA2022.3.2
 * @Author: Tenghw
 * @Date: 2023/04/01  18:14
 * @Description: 测试key是否可以设置为null
 */
public class Demo1 {
    public static void main0(String[] args) {
        Map<Object, Object> map1 = new HashMap<>();
        map1.put(null,1);
        map1.put(null,2);
        map1.put(null,3);
        for(Object key:map1.keySet()){
            System.out.println("key="+key+" ,value="+map1.get(key));
        }
    }

    public static void main(String[] args) {
        Map<Object, Object> map1 = new TreeMap<>();
        //map1.put("a0",3);
        //map1.put("a0",3);
        map1.put("a",1);
        map1.put("a",1);
        map1.put("b",null);
        map1.put("c",null);
        for(Object key:map1.keySet()){
            System.out.println("key="+key+" ,value="+map1.get(key));
        }
    }
}
